package com.example.weather1.mapper;

import com.example.weather1.entity.UserEntity;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {

    @Select("select * from wea_user")
    List<UserEntity> getAll();

    @Insert("insert into wea_user (wname, psd, phone) values('${wname}','${psd}','${phone}')")
    boolean add(UserEntity userEntity);

    @Select("select * from wea_user where wname='${wname}'")
    UserEntity getOneByName(@Param("wname") String wname);

    @Select("select * from wea_user where wname = '${wname}' and psd = '${psd}'")
    UserEntity login(UserEntity user);

    @Update("update wea_user set psd = '${psd}', wname = '${wname}' where phone = '${phone}'")
    boolean update(UserEntity user);
}


